package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TSdtTutorPrentInfo;
import cn.com.headfree.entity.TSkillLevelInfo;
import cn.com.headfree.mouldshow.dao.TSdtTutorPrentInfoDao;
import cn.com.headfree.mouldshow.dao.TSkillLevelInfoDao;
import cn.com.headfree.vo.simple.SkillLevelInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tSkillLevelInfoDao")
public class TSkillLevelInfoDaoImpl extends BaseDaoImpl<TSkillLevelInfo> implements TSkillLevelInfoDao {


    @Override
    public List<SkillLevelInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params = new Object[1];
        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.tech_type,t.qualifi_level,t.audit_org,t.org_level,t.cert_no,t.acqu_time,u.`NAME` as user_name from t_skill_level_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,GET_DIC('SkillAppraisalWork',t.tech_type) as tech_type,GET_DIC('QualificationLevel',t.qualifi_level) as qualifi_level,t.audit_org,GET_DIC('IdentificationUnitLevel',t.org_level) as org_level,t.cert_no,t.acqu_time,u.`NAME` as user_name from t_skill_level_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,GET_DIC('SkillAppraisalWork',t.tech_type) as tech_type,GET_DIC('QualificationLevel',t.qualifi_level) as qualifi_level,t.audit_org,GET_DIC('IdentificationUnitLevel',t.org_level) as org_level,t.cert_no,t.acqu_time,DATE_FORMAT(t.acqu_time,'%Y-%m-%d %H:%i:%s') as acqu_time_str,u.`NAME` as user_name from t_skill_level_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,GET_DIC('SkillAppraisalWork',t.tech_type) as tech_type,GET_DIC('QualificationLevel',t.qualifi_level) as qualifi_level,t.audit_org,GET_DIC('IdentificationUnitLevel',t.org_level) as org_level,t.cert_no,t.acqu_time,DATE_FORMAT(t.acqu_time,'%Y-%m-%d %H:%i:%s') as acqu_time_str,u.xb_name as user_name from t_skill_level_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on t.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(SkillLevelInfoVo.class, sql.toString(), null, false, params);
    }
}
